#ifndef SERVER_H
#define SERVER_H

#include"Data.h"
#include"User.h"
#include"Auth.h"
#include"httplib.h"

namespace aod{
#define WWWROOT "./www"
#define VIDEO_ROOT "/video"
#define IMAGE_ROOT "/image"
    extern TableVideo* tbv;
    extern TableUser* tbu;
    extern TableUserSession* tbus;
    extern TableVideoLikes* tbvl;

    class Server{
        public:
            Server(int port):_port(port), _auth(&_session_table)
            {}
            bool RunModule();
        private:
            int _port;
            httplib::Server _server;
            TableUserSession _session_table;
            Auth _auth;
        private:
            // 原有的视频API
            void Insert(const httplib::Request& req,httplib::Response& res);
            void Update(const httplib::Request& req,httplib::Response& res);
            void Delete(const httplib::Request& req,httplib::Response& res);
            void SelectAll(const httplib::Request& req,httplib::Response& res);
            void SelectOne(const httplib::Request& req,httplib::Response& res);
            
            // 用户管理API
            void UserRegister(const httplib::Request& req, httplib::Response& res);
            void UserLogin(const httplib::Request& req, httplib::Response& res);
            void UserLogout(const httplib::Request& req, httplib::Response& res);
            void UserRefreshSession(const httplib::Request& req, httplib::Response& res);
            void GetUserInfo(const httplib::Request& req, httplib::Response& res);
            void UpdateUserInfo(const httplib::Request& req, httplib::Response& res);
            
            // 视频点赞API
            void LikeVideo(const httplib::Request& req, httplib::Response& res);
            void GetVideoLikeStatus(const httplib::Request& req, httplib::Response& res);

    };
}

#endif



